define(["Zepto", 
        "underscore", 
        "Backbone", 
        "Handlebars",  
        "text!templates/teacher/teacher.html",
        "models/ricevimentodocente",
        "views/teacher/ricevimentoview"
], function($, _, Backbone, Handlebars, template, Ricevimentodocente) {
	
   
	  var TeacherPage = Backbone.View.extend({
		  
	        template: Handlebars.compile(template),

	        render: function(eventName) {
	        	
	        	this.$el.html(this.template(this.model.toJSON()));
	        	alert('nome: ' + this.model.get('nome'));
	           /* var ricd = this.model.get('id_ricevimento');
	            this.modelRicevimento = new Ricevimentodocente({objectId: ricd.objectId}); 
	            this.modelRicevimento.fetch();
	            alert('ric ' + this.modelRicevimento.get('stanza'));
	        	this.ricevimento = new RicevimentoView({
					el : $('#ricevimento', this.el),
					model : this.modelRicevimento
				});*/
	        	
	            return this;
	        },

	        postRender: function(eventName) {
	            var scrollableframe = new iScroll('scrollableframe',
                                      { useTransition:false,
                                        checkDOMChanges: true,
                                        hideScrollbar: true,
                                        fixedScrollbar:true,
                                        bounceLock: true }
                                    );
                var scroll1 = new iScroll('ricevimento',
                                      { useTransition:false,
                                        checkDOMChanges: true,
                                        hideScrollbar: true,
                                        fixedScrollbar:true,
                                        onBeforeScrollStart : function(e) { scrollableframe.disable();},
                                        onBeforeScrollEnd : function(e) { scrollableframe.enable();} } /*per evitare che scrollando un elemento
                                                                                                     figlio si scrolli anche il padre*/
                                    );
                var scroll2 = new iScroll('corsi',
                                      { useTransition:false,
                                        checkDOMChanges: true,
                                        hideScrollbar: true,
                                        fixedScrollbar:true,
                                        onBeforeScrollStart : function(e) { scrollableframe.disable();},
                                        onBeforeScrollEnd : function(e) { scrollableframe.enable();} } /*per evitare che scrollando un elemento
                                                                                                     figlio si scrolli anche il padre*/
                                    );
	        },


	        events: {
	            'click #appointmentbutton': 'getAppointment',
	            'touchstart .button': 'over',
	            'touchend .button': 'left',
	            'touchcancel .button': 'left',
	            'touchstart button': 'over',
	            'touchend button': 'left',
	            'touchcancel button': 'left',
	            'touchstart .ac-container article.selectable ul li': 'over',
	            'touchend .ac-container article.selectable ul li': 'left',
	            'touchcancel .ac-container article.selectable ul li': 'left'
	        },

	        getAppointment: function(event) {
	            
	            alert('getAppointment');
	        },

	        over: function(event) {
	            $(event.currentTarget).addClass('fake-active');
	        },

	        left: function(event) {
	            $(event.currentTarget).removeClass('fake-active');
	        }

	});

    return TeacherPage;

});

